﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace GmailMetroNotifier.Client.Business
{
    /// <summary>
    /// Represents an error during an authentication process.
    /// </summary>
    public class AuthenticationFailedException : Exception
    {
        /// <summary>
        /// Gets the credentials used in the failed authentication attempt.
        /// </summary>
        public NetworkCredential Credential { get; private set; }

        /// <summary>
        /// Initializes a new instance of the class
        /// </summary>
        public AuthenticationFailedException()
            : this(null, null, null)
        {

        }

        /// <summary>
        /// Initializes a new instance of the class using the given message.
        /// </summary>
        /// <param name="message">The message describing the error.</param>
        public AuthenticationFailedException(string message)
            : this(message, null, null)
        {

        }

        /// <summary>
        /// Initializes a new instance of the class using the given message and credential.
        /// </summary>
        /// <param name="message">The message describing the error.</param>
        /// <param name="credential">The credentials used in the failed authentication attempt.</param>
        public AuthenticationFailedException(string message, NetworkCredential credential)
            : this(message, credential, null)
        {

        }

        /// <summary>
        /// Initializes a new instance of the class using the given message and
        /// a reference to the inner exception that is the caused of this exception.
        /// </summary>
        /// <param name="message">The message describing the error.</param>
        /// <param name="innerException">The exception that is the cause of the current exception,
        /// or a null reference if no inner exception is specified.</param>
        public AuthenticationFailedException(string message, Exception innerException)
            : this(message, null, innerException)
        {

        }

        /// <summary>
        /// Initializes a new instance of the class using the given message and
        /// a reference to the inner exception that is the caused of this exception.
        /// </summary>
        /// <param name="message">The message describing the error.</param>
        /// <param name="credential">The credentials used in the failed authentication attempt.</param>
        /// <param name="innerException">The exception that is the cause of the current exception,
        /// or a null reference if no inner exception is specified.</param>
        public AuthenticationFailedException(string message, NetworkCredential credential, Exception innerException)
            : base(message, innerException)
        {
            this.Credential = credential;
        }
    }
}
